package com.zzgele.qmzb.api.web;

import com.alibaba.boot.dubbo.annotation.DubboConsumer;
import com.zzgele.qmzb.api.core.Result;
import com.zzgele.qmzb.api.core.ResultGenerator;
import com.zzgele.qmzb.api.model.About;
import com.zzgele.qmzb.api.service.AboutService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
* Created by Martin on 2017/07/13.
*/
@RestController
@RequestMapping("/about")
public class AboutController {
    private final Logger logger = LoggerFactory.getLogger(AboutController.class);

    @DubboConsumer
    private AboutService aboutService;


    @PostMapping("/list")
    public Result list() {
        List<HashMap> aboutListHashMap = aboutService.getList(null);

        return ResultGenerator.genSuccessResult(aboutListHashMap);
    }

    @PostMapping("/reg_agreement")
    public Result reg_agreement() {
        About about = aboutService.findById(5);

        String content = "注册协议";
        if (about != null) {
            content = about.getContent();
        }

        HashMap hashMap = new HashMap();
        hashMap.put("content", content);
        return ResultGenerator.genSuccessResult(hashMap);
    }
}
